<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" xmlns:c="http://www.springframework.org/schema/beans"/>
<!DOCTYPE html>
<html lang="en" >

<head>
    <meta charset="UTF-8">
    <title>Login Form</title>
    <link rel="stylesheet" href="../css/style.css">
</head>

<script src="../js/jquery-1.11.3.min.js"></script>

<body>
<div class="login">
    <div class="login-screen">
        <div class="app-title">
            <h1>Login</h1>
        </div>
        <from id="loginForm" action="${ctx}/Login/check" monthed="post">


            <div class="login-form">
                <div class="control-group">
                    <input type="text" class="login-field" name="ustuno" value="" placeholder="username" id="login-name">
                    <label class="login-field-icon fui-user" for="login-name"></label>
                </div>

                <div class="control-group">
                    <input type="password" class="login-field" name="upassword" value="" placeholder="password" id="login-pass">
                    <label class="login-field-icon fui-lock" for="login-pass"></label>
                </div>

                <a class="btn btn-primary btn-large btn-block" href="#">login</a>
                <a class="login-link" href="#">Lost your password?</a>
            </div>
        </from>
    </div>
</div>
</body>
<script type="text/javascript">

    $(function(){
        $('.btn-primary').click(function () {
            var username = $("input[name='ustuno']").val();
            var password = $("input[name='upassword']").val();
            if(username==""||password==""){
                alert("用户名或密码不能为空!");
                return false
            }
            var param ={
                ustuno:username,
                upassword:password
            }
            check(param);
        });

    })



    function check(formData){
        var url="${ctx}/Login/check";

        $.ajax({
            type : 'post',
            url : url,
            data : formData,
            success : function(data) {
                console.log(data);
                window.location.href="${ctx}/index"
            },
            error : function(XMLHttpRequest, textStatus, errorThrown) {
                alert(textStatus);
            }
        });
    }
</script>


</html>
